require(['./config'], () => {
    require(['server', 'swiper', 'nav', 'foot'], (server, Swiper) => {
        class Index {
            constructor() {
                this.init()
            }
            init() {
                let mySwiper = new Swiper('.swiper-container', {
                    scrollbar: {
                        el: '.swiper-scrollbar',
                    },
                    autoplay: true
                });
                $.get(server.baseServerUrl + '/api/v1/goods/select.php', resp => {
                    // bracelets, necklaces, earrings, rings
                    let necklaces = JSON.parse(resp).body.list.filter((item) => item.jewelryType == "necklaces");
                    let bracelets = JSON.parse(resp).body.list.filter((item) => item.jewelryType == "bracelets");
                    let earrings = JSON.parse(resp).body.list.filter((item) => item.jewelryType == "earrings");
                    let rings = JSON.parse(resp).body.list.filter((item) => item.jewelryType == "rings");

                    $('#necklaces img').attr('src', necklaces[0].img);
                    $('#bracelets img').attr('src', bracelets[0].img);
                    $('#earrings  img').attr('src', earrings[0].img);
                    $('#rings     img').attr('src', rings[0].img);
                    $('.main .father-class').on('click', 'a', function() {
                        open('/html/category.html?' + $(this).parents('.father-class').attr('type-title') + '=' + $(this).attr('je-type'));
                    })

                })


            }
        }
        new Index()
    })
})